package com.xdb.sqlparser.dialect.oracle.ast.clause;

import java.util.ArrayList;
import java.util.List;

import com.xdb.sqlparser.ast.SQLExpr;
import com.xdb.sqlparser.ast.AbstractSQLExprImpl;
import com.xdb.sqlparser.dialect.oracle.visitor.OracleASTVisitor;
import com.xdb.sqlparser.visitor.SQLAstVisitor;

public class OracleGroupingSetExpr extends AbstractSQLExprImpl {

	private final List<SQLExpr> parameters = new ArrayList<SQLExpr>();

	public List<SQLExpr> getParameters() {
		return parameters;
	}

	@Override
	protected void accept0(SQLAstVisitor visitor) {
		accept0((OracleASTVisitor) visitor);
	}

	protected void accept0(OracleASTVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, parameters);
		}
		visitor.endVisit(this);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof OracleGroupingSetExpr)) {
			return false;
		}
		OracleGroupingSetExpr other = (OracleGroupingSetExpr) obj;
		if (parameters == null) {
			if (other.parameters != null) {
				return false;
			}
		} else if (!parameters.equals(other.parameters)) {
			return false;
		}
		return true;
	}

}
